import os

# 获取当前目录
current_directory = os.getcwd()

# 初始化Markdown内容列表
md_content = [
    "# 当前目录文件列表\n\n",
    "| 类型 | 名称 |\n",
    "| --- | --- |\n"
]

# 获取当前目录下的所有文件和子目录，排除隐藏文件和目录
entries = [entry for entry in os.listdir(current_directory) if not entry.startswith('.')]

# 分类文件和目录
files = [entry for entry in entries if os.path.isfile(os.path.join(current_directory, entry))]
dirs = [entry for entry in entries if os.path.isdir(os.path.join(current_directory, entry))]

# 添加文件到Markdown表格
for file in files:
    md_content.append(f"| 文件 | {file} |\n")

# 添加目录到Markdown表格
for dir in dirs:
    md_content.append(f"| 目录 | {dir} |\n")

# 将Markdown内容写入文件
with open("file_list.md", "w", encoding="utf-8") as md_file:
    md_file.writelines(md_content)

print("Markdown文件已生成。")